import { PRICE_BAND_OPTIONS } from '@/constant/goods'
import { CPZ_OPTIONS, PURCHASEWAY_OPTIONS } from '@/constant/purchase'
import { Empty, FormInstance } from 'antd'
import dayjs from 'dayjs'
export const searchConfig = ({
  SupplierOption,
  handleSearchSupplier,
  classBig,
  DICTDATA,
  onBigClassIdChange,
  onBigClassIdClear,
  midClass,
  smallClass,
  tinyClass,
  form,
}: {
  SupplierOption: IOptionItem[]
  classBig: IOptionItem[]
  handleSearchSupplier: (newVal: string) => void
  onBigClassIdChange: (newVal: string, item: any) => void
  onBigClassIdClear: () => void
  DICTDATA: IDICTDATAType
  midClass: IOptionItem[]
  smallClass: IOptionItem[]
  tinyClass: IOptionItem[]
  form: FormInstance
}): IItemArray[] => {
  return [
    {
      label: '销售时间',
      name: 'saleStartDate',
      type: 'FixedRangePicker',
      config: {
        showTime: false,
        customFormat: 'YYYY-MM-DD',
        maxDate: dayjs().subtract(1, 'day'),
        presets: [
          {
            label: '最近7天',
            value: [dayjs().subtract(7, 'day'), dayjs().subtract(1, 'day')],
          },
          {
            label: '最近14天',
            value: [dayjs().subtract(14, 'day'), dayjs().subtract(1, 'day')],
          },
          {
            label: '昨天',
            value: [dayjs().subtract(1, 'day'), dayjs().subtract(1, 'day')],
          },
          {
            label: '上周',
            value: [dayjs().subtract(1, 'week').startOf('week'), dayjs().subtract(1, 'week').endOf('week')],
          },
          {
            label: '上个月',
            value: [dayjs().subtract(1, 'month').startOf('month'), dayjs().subtract(1, 'month').endOf('month')],
          },
        ],
        disabledDate: (current: any, { from }: any) => {
          if (from) {
            return current.isAfter(from.add(3, 'month')) || current.isBefore(from.subtract(3, 'month'))
          }
          return false
        },
      },
    },
    {
      name: 'branchOffice',
      label: '渠道',
      type: 'Select',
      option: [
        { label: '直营', value: '直营' },
        { label: '加盟', value: '加盟' },
      ],
      placeholder: '请选择渠道',
      config: {
        showSearch: true,
        filterOption: true,
        optionFilterProp: 'label',
      },
    },
    {
      label: '商品年份',
      name: 'year',
      type: 'FixedDatePicker',
      placeholder: '请选择商品年份',
      config: {
        picker: 'year',
        format: 'YYYY',
        customFormat: 'YYYY',
      },
    },
    {
      name: 'seasonGroupList',
      label: '季节分组',
      type: 'Select',
      option: DICTDATA.season_classify,
      placeholder: '请选择季节分组',
      config: {
        suffixIcon: null,
        showSearch: true,
        optionFilterProp: 'label',
        filterOption: true,
        mode: 'multiple',
        maxTagCount: 'responsive',
      },
    },
    {
      label: '大类',
      name: 'largeClassName',
      type: 'Select',
      option: classBig,
      config: {
        // onChange: onBigClassIdChange,
        onSelect: onBigClassIdChange,
        onClear: onBigClassIdClear,
      },
    },
    {
      label: '中类',
      name: 'midClassNameList',
      type: 'Select',
      option: midClass,
      config: {
        suffixIcon: null,
        showSearch: true,
        filterOption: true,
        mode: 'multiple',
        maxTagCount: 'responsive',
        fieldNames: { label: 'className', value: 'className' },
      },
    },
    {
      label: '小类',
      name: 'smallClassNameList',
      type: 'Select',
      option: smallClass,
      config: {
        suffixIcon: null,
        showSearch: true,
        filterOption: true,
        mode: 'multiple',
        maxTagCount: 'responsive',
        fieldNames: { label: 'className', value: 'className' },
        disabled: !form.getFieldValue('largeClassName'),
        placeholder: form.getFieldValue('largeClassName') ? '请选择小类' : '请先选择大类',
      },
    },
    {
      label: '细类',
      name: 'fineClassNameList',
      type: 'Select',
      option: tinyClass,
      config: {
        suffixIcon: null,
        showSearch: true,
        filterOption: true,
        mode: 'multiple',
        maxTagCount: 'responsive',
        fieldNames: { label: 'className', value: 'className' },
        disabled: !form.getFieldValue('largeClassName'),
        placeholder: form.getFieldValue('largeClassName') ? '请选择细类' : '请先选择大类',
      },
    },
    {
      label: '畅平滞标签',
      name: 'salesTag',
      type: 'Select',
      option: CPZ_OPTIONS,
      config: {
        suffixIcon: null,
        showSearch: true,
        optionFilterProp: 'label',
        filterOption: true,
      },
    },
    {
      name: 'priceTagCode',
      label: '价格带',
      type: 'Select',
      option: PRICE_BAND_OPTIONS,
      placeholder: '请选择价格带',
      config: {
        showSearch: true,
        filterOption: true,
        optionFilterProp: 'label',
      },
    },
    {
      name: 'ageCode',
      label: '年龄段',
      type: 'Select',
      option: DICTDATA.age_level,
      placeholder: '请选择年龄段',
      config: {
        showSearch: true,
        filterOption: true,
        optionFilterProp: 'label',
      },
    },
    {
      label: '采购方式',
      name: 'purchaseType',
      type: 'Select',
      option: PURCHASEWAY_OPTIONS,
      config: {
        showSearch: true,
        optionFilterProp: 'label',
      },
    },
  ]
}

export const useFormExport = (): IItemArray[] => {
  return [
    {
      label: '导出数据维度',
      name: 'exportDataTypeList',
      type: 'Checkbox',
      option: [
        { label: '款', value: 'SPU' },
        { label: '色', value: 'SKC' },
      ],
    },
  ]
}
